﻿// JavaScript File
/*
处理页面的用户交互事件
Processing Event of User Interactive Operation
Yang Xiaodong
2008-7-30
*/


var boolResize = false;

//数据源radio点击控制
function radioCheckSample(event)
{
    if (event.data.id == "radioMouse")
    {
        if($("#radioMouse").attr("checked") == true)
        {
            $("#radioMouse").attr("checked",false);
            $("#radioFile").attr("checked",true);
            addPoint = false;
        }
        else
        {
            $("#radioMouse").attr("checked",true);
            $("#radioFile").attr("checked",false);
            addPoint = true;
        }
    }    
    else
    {
        if($("#radioFile").attr("checked") == true)
        {
            $("#radioFile").attr("checked",false);
            $("#radioMouse").attr("checked",true);
            addPoint = true;
        }
        else
        {
            $("#radioFile").attr("checked",true);
            $("#radioMouse").attr("checked",false);
            addPoint = false;
        }  
    }      
}


//模型选择radio点击控制
function radioCheckModel(event)
{

    
    if(event.data.id == "radioLine")
    {
        if($("#radioLine").attr("checked") == true)
        {
            $("#radioLine").attr("checked",false);
            $("#radioExp").attr("checked",true);
            $("#radioLn").attr("checked",false);
        }
        else
        {
            $("#radioLine").attr("checked",true);
            $("#radioExp").attr("checked",false);
            $("#radioLn").attr("checked",false);
        }
        
    }
    else if (event.data.id == "radioExp")
    {
        if($("#radioExp").attr("checked") == true)
        {
            $("#radioExp").attr("checked",false);
            $("#radioLn").attr("checked",true);
            $("#radioLine").attr("checked",false);
        }
        else
        {
            $("#radioExp").attr("checked",true);
            $("#radioLn").attr("checked",false);
            $("#radioLine").attr("checked",false);
        }        
    }
    else
    {
        if($("#radioLn").attr("checked") == true)
        {
            $("#radioLn").attr("checked",false);
            $("#radioLine").attr("checked",true);
            $("#radioExp").attr("checked",false);
        }
        else
        {
            $("#radioLn").attr("checked",true);
            $("#radioLine").attr("checked",false);
            $("#radioExp").attr("checked",false);
        }            
    }
    

}


/*
User Load Event
*/
function checkUser()
{
    var userName = $("#username").attr("value");
    var userPassword = $("#password").attr("value");
    
//     var request = createRequest(); 
//     var strURL = "UserCheck.aspx?name=" + userName+"&pwd="+userPassword;
//     var myXD = new ActiveXObject("MSXML2.DOMDocument");
     
         var strURL = "Services/UserCheck.aspx";
         $.ajax({
            async: false,
            cache: false,
            url: strURL,
            data: "NAME=" + userName + "&PWD=" + userPassword + "&TMP=" + Math.random(),
            success: function(data){
                        var xmlDocument = data.documentElement;
                        var nodeNumber = xmlDocument.childNodes[0].attributes.length;
                        if(nodeNumber == 1)
                        {
                            alert("您的用户名或密码有错，请重新输入！");
                            return;
                        }
                        else
                        {
                            USER_NAME = xmlDocument.childNodes[0].attributes[0].nodeValue;
                            USER_ROLE_INDEX = xmlDocument.childNodes[0].attributes[1].nodeValue;
                            USER_DISTRICT_ID = xmlDocument.childNodes[0].attributes[2].nodeValue;
                            USER_DISTRICT_NAME = xmlDocument.childNodes[0].attributes[3].nodeValue;
                            USER_EMAIL = xmlDocument.childNodes[0].attributes[4].nodeValue;
                            USER_STATUS = xmlDocument.childNodes[0].attributes[5].nodeValue;
                            USER_LAT = xmlDocument.childNodes[0].attributes[6].nodeValue;
                            USER_LNG = xmlDocument.childNodes[0].attributes[7].nodeValue;
                        }
                        
                         $("#username").attr("value","");
                         $("#password").attr("value","");
                         
                         if(USER_STATUS == "1")
                         {
                             var strLocation = USER_LAT + "," + USER_LNG;
                             if (USER_LAT.length < 2 || USER_LNG.length < 2)
                             {
                                GLoadMap("");
                             }
                             else
                             {
                                GLoadMap(strLocation);
                             }
                             
                             
                             var txtWelcome = document.createTextNode(USER_NAME + "，欢迎您使用本系统！");
                             
                             var btnExit = document.createElement("input");
                             btnExit.type = "button";
                             btnExit.value = "退  出";
                             $(btnExit).bind("click",showLoginTable);
                             
                             $("#LoginBar").empty();
                             $("#LoginBar").append(txtWelcome);
                             $("#LoginBar").append(btnExit);  
                             return;
                             
                         }
                         else
                         {
                            alert("您的账户已经过期，请您重新申请或联系管理员！");
                            return;
                         }     
            }
         
         });
//         $.get(strURL,{ NAME:userName,
//                        PWD:userPassword,
//                        tmp:Math.random()
//                      },
//                      function(data){
//                        var xmlDocument = data.documentElement;
//                        var nodeNumber = xmlDocument.childNodes[0].attributes.length;
//                        if(nodeNumber == 1)
//                        {
//                            alert("您的用户名或密码有错，请重新输入！");
//                            return;
//                        }
//                        else
//                        {
//                            USER_NAME = xmlDocument.childNodes[0].attributes[0].nodeValue;
//                            USER_ROLE_INDEX = xmlDocument.childNodes[0].attributes[1].nodeValue;
//                            USER_DISTRICT_ID = xmlDocument.childNodes[0].attributes[2].nodeValue;
//                            USER_DISTRICT_NAME = xmlDocument.childNodes[0].attributes[3].nodeValue;
//                            USER_EMAIL = xmlDocument.childNodes[0].attributes[4].nodeValue;
//                            USER_STATUS = xmlDocument.childNodes[0].attributes[5].nodeValue;
//                            USER_LAT = xmlDocument.childNodes[0].attributes[6].nodeValue;
//                            USER_LNG = xmlDocument.childNodes[0].attributes[7].nodeValue;
//                        }
//                        
//                         $("#username").attr("value","");
//                         $("#password").attr("value","");
//                         
//                         if(USER_STATUS == "1")
//                         {
//                             var strLocation = USER_LAT + "," + USER_LNG;
//                             if (USER_LAT.length < 2 || USER_LNG.length < 2)
//                             {
//                                GLoadMap("");
//                             }
//                             else
//                             {
//                                GLoadMap(strLocation);
//                             }
//                             
//                             
//                             var txtWelcome = document.createTextNode(USER_NAME + "，欢迎您使用本系统！");
//                             
//                             var btnExit = document.createElement("input");
//                             btnExit.type = "button";
//                             btnExit.value = "退  出";
//                             $(btnExit).bind("click",showLoginTable);
//                             
//                             $("#LoginBar").empty();
//                             $("#LoginBar").append(txtWelcome);
//                             $("#LoginBar").append(btnExit);  
//                             return;
//                             
//                         }
//                         else
//                         {
//                            alert("您的账户已经过期，请您重新申请或联系管理员！");
//                            return;
//                         }     

//                         });
}

//    var strURL = "Services/UserCheck.aspx?NAME=" + userName + "&PWD=" + userPassword;
//    var request = createRequest();

//    try
//    {
//        request.open("GET",strURL,false);
//        request.send();
//        var xmlDoc = new ActiveXObject("MSXML2.DOMDocument");

//        xmlDoc.loadXML(request.responseText);
//        var xmlDocument = xmlDoc.documentElement;
//        var nodeNumber = xmlDocument.childNodes[0].attributes.length;
//        if(nodeNumber == 1)
//        {
//            alert("您的用户名或密码有错，请重新输入！");
//            return;
//        }
//        else
//        {
//            USER_NAME = xmlDocument.childNodes[0].attributes[0].nodeValue;
//            USER_ROLE_INDEX = xmlDocument.childNodes[0].attributes[1].nodeValue;
//            USER_DISTRICT_ID = xmlDocument.childNodes[0].attributes[2].nodeValue;
//            USER_DISTRICT_NAME = xmlDocument.childNodes[0].attributes[3].nodeValue;
//            USER_EMAIL = xmlDocument.childNodes[0].attributes[4].nodeValue;
//            USER_STATUS = xmlDocument.childNodes[0].attributes[5].nodeValue;
//            USER_LAT = xmlDocument.childNodes[0].attributes[6].nodeValue;
//            USER_LNG = xmlDocument.childNodes[0].attributes[7].nodeValue;
//        }
//        
//         $("#username").attr("value","");
//         $("#password").attr("value","");
//         
//         if(USER_STATUS == "1")
//         {
//             var strLocation = USER_LAT + "," + USER_LNG;
//             if (USER_LAT.length < 2 || USER_LNG.length < 2)
//             {
//                GLoadMap("");
//             }
//             else
//             {
//                GLoadMap(strLocation);
//             }
//             
//             
//             var txtWelcome = document.createTextNode(USER_NAME + "，欢迎您使用本系统！");
//             
//             var btnExit = document.createElement("input");
//             btnExit.type = "button";
//             btnExit.value = "退  出";
//             $(btnExit).bind("click",function() {showLoginTable();});
//             
//             $("#LoginBar").empty();
//             $("#LoginBar").append(txtWelcome);
//             $("#LoginBar").append(btnExit);  
//             
////             $('#wizard').empty();
////             $("#DivMenuControl").css("visibility","hidden");
////             $("#infoTable").css("visibility","hidden");
////             $('#infoTable').empty();
////                 document.getElementById("LoginBar").appendChild(txtWelcome);           
////                 document.getElementById("LoginBar").appendChild(btnExit);           
//         }
//         else
//         {
//            alert("您的账户已经过期，请您重新申请或联系管理员！");
//            //return;
//         }     
//     }
//     catch(err)
//     {
//         return "";
//         $("#username").attr("value","");
//         $("#password").attr("value","");
//     }
//}





	
function showLoginTable()
{
    
    //$("#LoginTable").css("visibility","visible");
    $("#LoginBar").empty();
    USER_NAME = "";
    USER_DISTRICT_ID = "";
    USER_ROLE_INDEX = "";
    USER_STATUS = "";
    
    var username = document.createTextNode("用户名：");
    var password = document.createTextNode("密码：");
    var usernameTextbox = document.createElement("input");
    usernameTextbox.type = "text";
    usernameTextbox.id = "username";
    var passwordTextbox = document.createElement("input");
    passwordTextbox.type = "password";
    passwordTextbox.id = "password";
    var loginButton = document.createElement("input");
    loginButton.type = "submit";
    loginButton.value = "登 录";
    $(loginButton).bind("click",checkUser);

    
    var loginTable = document.createElement("table");
    var tbody = document.createElement("tbody");
    loginTable.appendChild(tbody);
    
    tbody.insertRow(0);
    tbody.rows[0].insertCell(0);  
    tbody.rows[0].cells[0].appendChild(username);
    tbody.rows[0].cells[0].appendChild(usernameTextbox);
    tbody.rows[0].insertCell(1);
    tbody.rows[0].cells[1].appendChild(password);
    tbody.rows[0].cells[1].appendChild(passwordTextbox);
    tbody.rows[0].insertCell(2);
    tbody.rows[0].cells[2].appendChild(loginButton);
    
//    $(loginTable).addClass();
    
    $("#LoginBar").append(loginTable);
    if(typeof(gmap) != "undefined")
    {    
        gmap.clearOverlays();
        $('#wizard').empty();
        $("#DivMenuControl").css("visibility","hidden");
        $("#infoTable").css("visibility","hidden");
        $('#infoTable').empty();
    }
}	


/*
Close Legend Div
*/
function closeLegend()
{
    if($('#legendDiv').children().length > 0)
    {
        $('#legendDiv').empty();
    }
    $('#legendDiv').addClass("legendMin");
    $('#legendDiv').width("4");
    
    resizePage();
    GLoadMap("");
}


/*
Unfold Legend Div
*/
function unfoldLegend()
{
    if(MAP_TYPE == "GMAP" || MAP_TYPE == "GIMAGE")
    {
        alert("您现在并没有使用地图分析功能，因此暂时不能提供图例！");
        return;
    }

    lastMapType = MAP_TYPE; //记录生成图例之前的地图类型；
    if ($('#legendDiv').width() >10)
    {
        if($('#legendDiv').children().length > 0)
        {
            $('#legendDiv').empty();
        }
        $('#legendDiv').addClass("legendMin");
        $('#legendDiv').width("0");
        $('#legendDiv').css("visibility","hidden");
//        
        resizePage();
//        if(MAP_TYPE != "IMSMAPONLY")
//            MAP_TYPE = "IMSMAP";
//        getIMSMap(MAP_TYPE);
    }  
    else
    {  
        if($('#legendDiv').children().length > 0)
        {
            $('#legendDiv').empty();
        }
        $('#legendDiv').removeClass();
    //    $('#legendDiv').css("background-image","");
        
        var legendButton1 = document.createElement("span");
        legendButton1.className = "legendbutton";
        legendButton1.id = "close";
        legendButton1.alt = "关闭";
        legendButton1.onclick = closeLegend;

        var legendButton2 = document.createElement("span");
        legendButton2.className = "legendbutton";
        legendButton2.id = "min";
        
        //var legendUrl = createIMSMap("legend");
//        var imgLegend = document.createElement("img");
//        imgLegend.id = "imgLegend";
//        imgLegend.src = legendUrl;
//        imgLegend.alt = "图例";
        
        with($('#legendDiv'))
        {
            append(legendButton1);
            append(legendButton2);
            //append(imgLegend);
            addClass("legend");
            width("250");
            css("visibility","visible");
        }
        resizePage();
        MAP_TYPE = "IMSLEGEND";
//*******************************************************88
            var tempData=$("#forData").data("dt");
		    if(tempData!=undefined)
		    {
			    //alert($("#forData").data("dt"));
			    if(tempData=="disease")
			    {
			        getIMSMap_Disease(MAP_TYPE);
			    }else
			    {
			        getIMSMap(MAP_TYPE);
			    }
		    }else
		    {
			    //alert("no Data!");
			    getIMSMap(MAP_TYPE);
		    }
//********************************************************88
    }
    
//    if ($('#legendDiv').width() >10)
//    {
//        MAP_TYPE = "IMSLEGEND";
//        getIMSMap(MAP_TYPE);
//    }
//    flag = "IMSLEGEND";
//    if(MAP_TYPE == "IMSMAP" && MAP_TYPE != "IMSLEGEND")
//        getIMSMap(flag);
//    GLoadMap("");
}


//控制左侧工具栏的显示
function collapseMenuBox()
{
    var leftinfo = $("#leftInfo");
//    var menubox = $("#menuBox");
    
    if(leftinfo.width() > 10)
    {
//        menubox.width(0);
//        $("#menuBox > div").width(0);
        leftinfo.width(2);
    }
    else
    {
//        menubox.width(390);
//        $("#menuBox > div").width(376);
        leftinfo.width(396);
    }
    
//    if(flagMenu)
//    {
//        $("#leftInfo").hide("slow"); 
//    }
//    else
//    {
//        $("#leftInfo").show("slow"); 
//    }
//    flagMenu = !flagMenu;    
//    
//    var childrenElement = $("#leftInfo").children(); 
//    childrenElement.each(function(){
//        if(!flagWizard)
//            this.style.visibility = "hidden";
//        else
//            this.style.visibility = "visible";
//    });  
      
    resizePage();
    
//    GLoadMap("");    
}


function collapseMenu()
{
    $("#wizard").slideToggle("slow");
    flagWizard = !flagWizard;
    var childrenElement = $("#wizard").children(); 
    childrenElement.each(function(){
        if(!flagWizard)
            this.style.visibility = "hidden";
        else
            this.style.visibility = "visible";
    });    
}

/*
resize window
*/

//window.onresize = function() 
//{
//    if (boolResize == false)
//    {
//        resizePage();
//        boolResize = true;
//    }
    
//    if (boolResize == false)
//    {
//        GLoadMap("");
//        boolResize = true;
//        setTimeout("resetBoolResize()",1000);
//    }
//    var contentWidth;
//    var legend = $("#legendDiv");
//    if(legend.children().length <2 )
//    {
//        contentWidth =document.body.clientWidth - 254;
//    }
//    else
//    {
//        contentWidth =document.body.clientWidth - 510;
//    }
//    $("#map").width(contentWidth);
//    
//    var contentHeight = document.body.clientHeight - 180;
//    if (contentHeight > (window.screen.height - 300)) 
//        contentHeight = (window.screen.height - 300);
//    
//    $("#map").height(contentHeight);
//    legend.height(contentHeight);
//    $("#info").height(contentHeight-240);
//}

function resizePage()
{
    var i = 0;
    var offsetTop = 0;
    var offsetLeft = 0;
    var mapElem = $("#map");
    var legend = $("#legendDiv");
    var menubox = $("#menuBox");
    var leftControl = $("#leftControl");
    
    
    for (var elem = mapElem; elem && elem.offsetParent.tagName != "body" ; elem = elem.offsetParent()) 
    {
        offsetTop += elem.offset().top;
        offsetLeft += elem.offset().left;
        if(elem.offset().top == 0 && elem.offset().left == 0) break;
//        i++;
//        if (i>10) break;
    }
    if (offsetLeft < 10 ) offsetLeft = 402;
    var map_height = $(window).height() - offsetTop - 48;
    var map_width = $(window).width() - offsetLeft - 16;
    if(!flagMenu) map_width += 400;
    //var map_height = height;
    if (map_height >= 0) 
    {
        mapElem.height(map_height);
        legend.height(map_height);
        menubox.height(map_height + 48);
        leftControl.height(map_height + 48);
    }
    if (map_width>=0)
    {
        if(legend.children().length <2 )
            mapElem.width(map_width - 4);
        else
            mapElem.width(map_width - 268);
    }
    if(typeof(gmap) != "undefined")
        gmap.checkResize();
}



function loadRSIndexTable(fileName)
{
    var SampleParcelsXmlLocation = "data/" + fileName;// + ".xml";
    var xmlDoc = LoadXML(SampleParcelsXmlLocation);
    //var xmlDocument = xmlDoc.documentElement;
    //markerSampleRSPoints(xmlDocument);
    markerSampleRSPoints(xmlDoc);
    //var tableTitleNames = new Array("地块编号","纬度","经度","叶面积指数","叶片含水量","比叶重","植株总干重","NDVI","NDWI","NRI");
    

}

function markerCoustomSamplePoint(xmlDocument)
{
    var tableTitleNames = new Array("样点编号","经度","纬度","自定义植被指数");
    var tableTitles = new Array();
    for(var i = 0; i < tableTitleNames.length; i++){
        tableTitles[i] = document.createTextNode(tableTitleNames[i]);
    }
    var nodes = xmlDocument.getElementsByTagName("Parcel");
    var ParcelsNumber = nodes.length;//xmlDocument.childNodes.length;
    
    
    var ParcelsVaule = new Array();
    
    
    for(var i = 0; i < ParcelsNumber; i++)
    {
        ParcelsVaule[i] = new Array();
        ParcelsVaule[i][0] = document.createTextNode(nodes[i].attributes[0].nodeValue);  //pointid
        ParcelsVaule[i][1] = document.createTextNode(nodes[i].attributes[1].nodeValue); //lat
        ParcelsVaule[i][2] = document.createTextNode(nodes[i].attributes[2].nodeValue); //lon
        ParcelsVaule[i][3] = document.createTextNode(nodes[i].attributes[3].nodeValue); //ndwi
//        ParcelsVaule[i][4] = document.createTextNode(nodes[i].attributes[6].nodeValue); //ndwi2
//        ParcelsVaule[i][5] = document.createTextNode(nodes[i].attributes[7].nodeValue); //ndvi
//        ParcelsVaule[i][6] = document.createTextNode(nodes[i].attributes[8].nodeValue); //NRI
//        ParcelsVaule[i][7] = document.createTextNode(nodes[i].attributes[9].nodeValue); //NSI
//        ParcelsVaule[i][8] = document.createTextNode(nodes[i].attributes[10].nodeValue);//WI
//        ParcelsVaule[i][9] = document.createTextNode(nodes[i].attributes[11].nodeValue);//G_SWIR
//        ParcelsVaule[i][10] = document.createTextNode(nodes[i].attributes[12].nodeValue);//G_SWIR2
//        ParcelsVaule[i][11] = document.createTextNode(nodes[i].attributes[13].nodeValue);//植株总干重
//        ParcelsVaule[i][12] = document.createTextNode(nodes[i].attributes[14].nodeValue);//叶面积指数
//        ParcelsVaule[i][13] = document.createTextNode(nodes[i].attributes[15].nodeValue);//比叶重
//        ParcelsVaule[i][14] = document.createTextNode(nodes[i].attributes[16].nodeValue);//叶片含水量
    }
    
    gmap.clearOverlays();
    //var marker = new Array();
    for(var i = 0; i < ParcelsNumber; i++ ){
        var pointLocation =new GPoint(parseFloat(ParcelsVaule[i][1].nodeValue),parseFloat(ParcelsVaule[i][2].nodeValue));
        var strHtml = "<table><tr><td>";
        strHtml += "X</td><td>" + pointLocation.x + "</td></tr><tr><td>";
        strHtml += "Y</td><td>" + pointLocation.y + "</td></tr><tr><td>";
        strHtml += "自定义植被指数</td><td>" + ParcelsVaule[i][3].nodeValue + "</td></tr><tr><td>";
//        strHtml += "LAI</td><td>" + ParcelsVaule[i][12].nodeValue + "</td></tr><tr><td>";
//        strHtml += "NDVI</td><td>" + ParcelsVaule[i][5].nodeValue + "</td></tr><tr><td>";
//        strHtml += "NDWI</td><td>" + ParcelsVaule[i][3].nodeValue + "</td></tr>";
        strHtml += "</table>";

        
        createMarker(pointLocation, gmap, strHtml);
//        marker[i] = new GMarker(pointLocation);
//        GEvent.addListener(marker, "click", function() {
//            //html=html0 + createMarkerWeather(point, request);;
//            marker[i].openInfoWindowHtml(strHtml);
//        });
//        gmap.addOverlay(marker[i]);
    }
    
    
    var table = new DataTable(tableTitles,ParcelsVaule,0);
    //$(table).addClass("viewTable");
    with($(table))
    {
        width(380);
        height(400);
    }
    
    var divTable = document.createElement("div");
    divTable.className = "resultTable";
    divTable.appendChild(table);
    
    with($("#infoTable"))
    {
        empty();
        append(divTable);
        css("visibility", "visible");
    }
    $("#DivMenuControl").css("visibility", "visible");
    hideWaitImage();

}

function markerSampleRSPoints(xmlDocument)
{
    var tableTitleNames = new Array("地块编号","经度","纬度","NDWI", "NDWI2", "NDVI", "NRI", "NSI", "WI", "GWIR", "GWIR2","植株总干重","叶面积指数","比叶重","叶片含水量");
    var tableTitles = new Array();
    for(var i = 0; i < tableTitleNames.length; i++){
        tableTitles[i] = document.createTextNode(tableTitleNames[i]);
    }
    var nodes = xmlDocument.getElementsByTagName("Parcel");
    var ParcelsNumber = nodes.length;//xmlDocument.childNodes.length;
    
    
    var ParcelsVaule = new Array();
    
    
    for(var i = 0; i < ParcelsNumber; i++)
    {
        ParcelsVaule[i] = new Array();
        ParcelsVaule[i][0] = document.createTextNode(nodes[i].attributes[0].nodeValue);  //pointid
        ParcelsVaule[i][1] = document.createTextNode(nodes[i].attributes[1].nodeValue); //lat
        ParcelsVaule[i][2] = document.createTextNode(nodes[i].attributes[2].nodeValue); //lon
        ParcelsVaule[i][3] = document.createTextNode(nodes[i].attributes[5].nodeValue); //ndwi
        ParcelsVaule[i][4] = document.createTextNode(nodes[i].attributes[6].nodeValue); //ndwi2
        ParcelsVaule[i][5] = document.createTextNode(nodes[i].attributes[7].nodeValue); //ndvi
        ParcelsVaule[i][6] = document.createTextNode(nodes[i].attributes[8].nodeValue); //NRI
        ParcelsVaule[i][7] = document.createTextNode(nodes[i].attributes[9].nodeValue); //NSI
        ParcelsVaule[i][8] = document.createTextNode(nodes[i].attributes[10].nodeValue);//WI
        ParcelsVaule[i][9] = document.createTextNode(nodes[i].attributes[11].nodeValue);//G_SWIR
        ParcelsVaule[i][10] = document.createTextNode(nodes[i].attributes[12].nodeValue);//G_SWIR2
        ParcelsVaule[i][11] = document.createTextNode(nodes[i].attributes[13].nodeValue);//植株总干重
        ParcelsVaule[i][12] = document.createTextNode(nodes[i].attributes[14].nodeValue);//叶面积指数
        ParcelsVaule[i][13] = document.createTextNode(nodes[i].attributes[15].nodeValue);//比叶重
        ParcelsVaule[i][14] = document.createTextNode(nodes[i].attributes[16].nodeValue);//叶片含水量
    }
    
    gmap.clearOverlays();
    //var marker = new Array();
    for(var i = 0; i < ParcelsNumber; i++ ){
        var pointLocation =new GPoint(parseFloat(ParcelsVaule[i][1].nodeValue),parseFloat(ParcelsVaule[i][2].nodeValue));
        var strHtml = "<table><tr><td>";
        strHtml += "X</td><td>" + pointLocation.x + "</td></tr><tr><td>";
        strHtml += "Y</td><td>" + pointLocation.y + "</td></tr><tr><td>";
        strHtml += "LAI</td><td>" + ParcelsVaule[i][12].nodeValue + "</td></tr><tr><td>";
        strHtml += "叶片含水量</td><td>" + ParcelsVaule[i][14].nodeValue + "</td></tr><tr><td>";
        strHtml += "NDVI</td><td>" + ParcelsVaule[i][5].nodeValue + "</td></tr><tr><td>";
        strHtml += "NDWI</td><td>" + ParcelsVaule[i][3].nodeValue + "</td></tr>";
        strHtml += "</table>";

        
        createMarker(pointLocation, gmap, strHtml);
//        marker[i] = new GMarker(pointLocation);
//        GEvent.addListener(marker, "click", function() {
//            //html=html0 + createMarkerWeather(point, request);;
//            marker[i].openInfoWindowHtml(strHtml);
//        });
//        gmap.addOverlay(marker[i]);
    }
    
    
    var table = new DataTable(tableTitles,ParcelsVaule,0);
    //$(table).addClass("viewTable");
    with($(table))
    {
        width(380);
        height(400);
    }
    
    var divTable = document.createElement("div");
    divTable.className = "resultTable";
    divTable.appendChild(table);
    
    with($("#infoTable"))
    {
        empty();
        append(divTable);
        css("visibility", "visible");
    }
    $("#DivMenuControl").css("visibility", "visible");
    hideWaitImage();

}

//样点与单产输出到表格
//11-3日下午------>
function markerSampleRSPointsAndYield(xmlDocument)
{
    var tableTitleNames = new Array("地块编号","经度","纬度","NDWI", "NDWI2", "NDVI", "NRI", "NSI", "WI", "GWIR", "GWIR2","单产(千克)");
    var tableTitles = new Array();
    for(var i = 0; i < tableTitleNames.length; i++){
        tableTitles[i] = document.createTextNode(tableTitleNames[i]);
    }
    var nodes = xmlDocument.getElementsByTagName("Parcel");
    var ParcelsNumber = nodes.length;//xmlDocument.childNodes.length;
    
    
    var ParcelsVaule = new Array();
    
    
    for(var i = 0; i < ParcelsNumber; i++)
    {
        ParcelsVaule[i] = new Array();
        ParcelsVaule[i][0] = document.createTextNode(nodes[i].attributes[0].nodeValue);  //pointid
        ParcelsVaule[i][1] = document.createTextNode(nodes[i].attributes[1].nodeValue); //
        ParcelsVaule[i][2] = document.createTextNode(nodes[i].attributes[2].nodeValue); //
        ParcelsVaule[i][3] = document.createTextNode(nodes[i].attributes[5].nodeValue); //
        ParcelsVaule[i][4] = document.createTextNode(nodes[i].attributes[6].nodeValue); //
        ParcelsVaule[i][5] = document.createTextNode(nodes[i].attributes[7].nodeValue); //
        ParcelsVaule[i][6] = document.createTextNode(nodes[i].attributes[8].nodeValue); //
        ParcelsVaule[i][7] = document.createTextNode(nodes[i].attributes[9].nodeValue); //
        ParcelsVaule[i][8] = document.createTextNode(nodes[i].attributes[10].nodeValue);//
        ParcelsVaule[i][9] = document.createTextNode(nodes[i].attributes[11].nodeValue);//
        ParcelsVaule[i][10] = document.createTextNode(nodes[i].attributes[12].nodeValue);//
        ParcelsVaule[i][11] = document.createTextNode(nodes[i].attributes[17].nodeValue);//单产
    }
    
    gmap.clearOverlays();
    for(var i = 0; i < ParcelsNumber; i++ ){
        var pointLocation =new GPoint(parseFloat(ParcelsVaule[i][1].nodeValue),parseFloat(ParcelsVaule[i][2].nodeValue));
        var strHtml = "<table><tr><td>";
        strHtml += "X</td><td>" + pointLocation.x + "</td></tr><tr><td>";
        strHtml += "Y</td><td>" + pointLocation.y + "</td></tr><tr><td>";
        //strHtml += "LAI</td><td>" + ParcelsVaule[i][10].nodeValue + "</td></tr><tr><td>";
        strHtml += "单产:</td><td>" + ParcelsVaule[i][11].nodeValue + "</td></tr><tr><td>";
        strHtml += "NDVI:</td><td>" + ParcelsVaule[i][5].nodeValue + "</td></tr><tr><td>";
        strHtml += "NDWI:</td><td>" + ParcelsVaule[i][3].nodeValue + "</td></tr>";
        strHtml += "</table>";        
        createMarker(pointLocation, gmap, strHtml);
    }
    
    var table = new DataTable(tableTitles,ParcelsVaule,0);
    with($(table))
    {
        width(380);
        height(400);
    }
    
    var divTable = document.createElement("div");
    divTable.className = "resultTable";
    divTable.appendChild(table);
    
    with($("#infoTable"))
    {
        empty();
        append(divTable);
        css("visibility", "visible");
    }
    $("#DivMenuControl").css("visibility", "visible");
    hideWaitImage();

}
//样点与单产输出到表格
//<------11-3日下午

//11-10日添加---->
function markerSampleRSPointsAndQuality(xmlDocument)
{
    var tableTitleNames = new Array("地块编号","经度","纬度","NCL","CND","CHL_A","DEN_CHLA","CHL_AB","DEN_CHL","NDWI", "NDWI2", "NDVI", "NRI", "NSI", "WI", "GWIR", "GWIR2");
    var tableTitles = new Array();
    for(var i = 0; i < tableTitleNames.length; i++){
        tableTitles[i] = document.createTextNode(tableTitleNames[i]);
    }
    var nodes = xmlDocument.getElementsByTagName("Parcel");
    var ParcelsNumber = nodes.length;//xmlDocument.childNodes.length;
    
    
    var ParcelsVaule = new Array();
    
    
    for(var i = 0; i < ParcelsNumber; i++)
    {
        ParcelsVaule[i] = new Array();
        ParcelsVaule[i][0] = document.createTextNode(nodes[i].attributes[0].nodeValue);  //pointid
        ParcelsVaule[i][1] = document.createTextNode(nodes[i].attributes[7].nodeValue); //
        ParcelsVaule[i][2] = document.createTextNode(nodes[i].attributes[8].nodeValue);//
        ParcelsVaule[i][3] = document.createTextNode(nodes[i].attributes[1].nodeValue);//
        ParcelsVaule[i][4] = document.createTextNode(nodes[i].attributes[2].nodeValue);//
        ParcelsVaule[i][5] = document.createTextNode(nodes[i].attributes[3].nodeValue); //
        ParcelsVaule[i][6] = document.createTextNode(nodes[i].attributes[4].nodeValue); //
        ParcelsVaule[i][7] = document.createTextNode(nodes[i].attributes[5].nodeValue); //
        ParcelsVaule[i][8] = document.createTextNode(nodes[i].attributes[11].nodeValue); //
        ParcelsVaule[i][9] = document.createTextNode(nodes[i].attributes[12].nodeValue); //
        ParcelsVaule[i][10] = document.createTextNode(nodes[i].attributes[13].nodeValue); //
        ParcelsVaule[i][11] = document.createTextNode(nodes[i].attributes[14].nodeValue);//
        ParcelsVaule[i][12] = document.createTextNode(nodes[i].attributes[15].nodeValue);//
        ParcelsVaule[i][13] = document.createTextNode(nodes[i].attributes[16].nodeValue);//
        ParcelsVaule[i][14] = document.createTextNode(nodes[i].attributes[17].nodeValue);//
        ParcelsVaule[i][15] = document.createTextNode(nodes[i].attributes[18].nodeValue);//
        ParcelsVaule[i][16] = document.createTextNode(nodes[i].attributes[19].nodeValue);//
    }
    
    gmap.clearOverlays();
    for(var i = 0; i < ParcelsNumber; i++ ){
        var pointLocation =new GPoint(parseFloat(ParcelsVaule[i][1].nodeValue),parseFloat(ParcelsVaule[i][2].nodeValue));
        var strHtml = "<table><tr><td>";
        strHtml += "X</td><td>" + pointLocation.x + "</td></tr><tr><td>";
        strHtml += "Y</td><td>" + pointLocation.y + "</td></tr><tr><td>";
        //strHtml += "LAI</td><td>" + ParcelsVaule[i][10].nodeValue + "</td></tr><tr><td>";
        strHtml += "NCL:</td><td>" + ParcelsVaule[i][3].nodeValue + "</td></tr><tr><td>";
        strHtml += "CND:</td><td>" + ParcelsVaule[i][4].nodeValue + "</td></tr><tr><td>";
        strHtml += "CHL_A:</td><td>" + ParcelsVaule[i][5].nodeValue + "</td></tr><tr><td>";
        strHtml += "DEN_CHLA:</td><td>" + ParcelsVaule[i][6].nodeValue + "</td></tr><tr><td>";
        strHtml += "CHL_AB:</td><td>" + ParcelsVaule[i][7].nodeValue + "</td></tr><tr><td>";
        strHtml += "DEN_CHL:</td><td>" + ParcelsVaule[i][8].nodeValue + "</td></tr><tr><td>";
        strHtml += "NDVI</td><td>" + ParcelsVaule[i][13].nodeValue + "</td></tr><tr><td>";
        strHtml += "NDWI</td><td>" + ParcelsVaule[i][11].nodeValue + "</td></tr>";
        strHtml += "</table>";        
        createMarker(pointLocation, gmap, strHtml);
    }
    
    var table = new DataTable(tableTitles,ParcelsVaule,0);
    with($(table))
    {
        width(380);
        height(400);
    }
    
    var divTable = document.createElement("div");
    divTable.className = "resultTable";
    divTable.appendChild(table);
    
    with($("#infoTable"))
    {
        empty();
        append(divTable);
        css("visibility", "visible");
    }
    $("#DivMenuControl").css("visibility", "visible");
    hideWaitImage();
}
//<----11-10日添加

//植被指数与品质输出成表格
//11-24日添加
function markerSampleRSPointsAndRSQuality(xmlDocument)
{
    var tableTitleNames = new Array("地块编号",
                                    "经度",
                                    "纬度",
                                    "CRUDEPP",
                                    "WETGP",
                                    "SETTIME",
                                    "NCONTENT",                                   
                                    "NDWI", 
                                    "NDWI2", 
                                    "NDVI", 
                                    "NRI", 
                                    "NSI", 
                                    "WI", 
                                    "GWIR", 
                                    "GWIR2");
    var tableTitles = new Array();
    for(var i = 0; i < tableTitleNames.length; i++){
        tableTitles[i] = document.createTextNode(tableTitleNames[i]);
    }
    var nodes = xmlDocument.getElementsByTagName("Parcel");
    var ParcelsNumber = nodes.length;//xmlDocument.childNodes.length;
    
    
    var ParcelsVaule = new Array();
    
    
    for(var i = 0; i < ParcelsNumber; i++)
    {
        ParcelsVaule[i] = new Array();
        ParcelsVaule[i][0] = document.createTextNode(nodes[i].attributes[0].nodeValue);  //pointid
        ParcelsVaule[i][1] = document.createTextNode(nodes[i].attributes[5].nodeValue); //lon
        ParcelsVaule[i][2] = document.createTextNode(nodes[i].attributes[6].nodeValue);//lat
        ParcelsVaule[i][3] = document.createTextNode(nodes[i].attributes[1].nodeValue);//CRUDEPP
        ParcelsVaule[i][4] = document.createTextNode(nodes[i].attributes[2].nodeValue);//WETGP
        ParcelsVaule[i][5] = document.createTextNode(nodes[i].attributes[3].nodeValue); //SETTIME
        ParcelsVaule[i][6] = document.createTextNode(nodes[i].attributes[4].nodeValue); //NCONTENT
        ParcelsVaule[i][7] = document.createTextNode(nodes[i].attributes[9].nodeValue); //NDWI
        ParcelsVaule[i][8] = document.createTextNode(nodes[i].attributes[10].nodeValue); //NDWI2
        ParcelsVaule[i][9] = document.createTextNode(nodes[i].attributes[11].nodeValue); //NDVI
        ParcelsVaule[i][10] = document.createTextNode(nodes[i].attributes[12].nodeValue); //NRI
        ParcelsVaule[i][11] = document.createTextNode(nodes[i].attributes[13].nodeValue);//NSI
        ParcelsVaule[i][12] = document.createTextNode(nodes[i].attributes[14].nodeValue);//WI
        ParcelsVaule[i][13] = document.createTextNode(nodes[i].attributes[15].nodeValue);//G_SWIR
        ParcelsVaule[i][14] = document.createTextNode(nodes[i].attributes[16].nodeValue);//G_SWIR2
    }
    
    gmap.clearOverlays();
    for(var i = 0; i < ParcelsNumber; i++ ){
        var pointLocation =new GPoint(parseFloat(ParcelsVaule[i][1].nodeValue),parseFloat(ParcelsVaule[i][2].nodeValue));
        var strHtml = "<table><tr><td>";
        strHtml += "X</td><td>" + pointLocation.x + "</td></tr><tr><td>";
        strHtml += "Y</td><td>" + pointLocation.y + "</td></tr><tr><td>";
        //strHtml += "LAI</td><td>" + ParcelsVaule[i][10].nodeValue + "</td></tr><tr><td>";
        strHtml += "CRUDEPP:</td><td>" + ParcelsVaule[i][3].nodeValue + "</td></tr><tr><td>";
        strHtml += "WETGP:</td><td>" + ParcelsVaule[i][4].nodeValue + "</td></tr><tr><td>";
        strHtml += "SETTIME:</td><td>" + ParcelsVaule[i][5].nodeValue + "</td></tr><tr><td>";
        strHtml += "NCONTENT:</td><td>" + ParcelsVaule[i][6].nodeValue + "</td></tr><tr><td>";        
        strHtml += "NDVI</td><td>" + ParcelsVaule[i][9].nodeValue + "</td></tr><tr><td>";
        strHtml += "NDWI</td><td>" + ParcelsVaule[i][7].nodeValue + "</td></tr>";
        strHtml += "</table>";        
        createMarker(pointLocation, gmap, strHtml);
    }
    
    var table = new DataTable(tableTitles,ParcelsVaule,0);
    with($(table))
    {
        width(380);
        height(400);
    }
    
    var divTable = document.createElement("div");
    divTable.className = "resultTable";
    divTable.appendChild(table);
    
    with($("#infoTable"))
    {
        empty();
        append(divTable);
        css("visibility", "visible");
    }
    $("#DivMenuControl").css("visibility", "visible");
    hideWaitImage();
}


//加载样点文件观测数据
//function loadSamplePointsTable(event)
function loadSamplePointsTable()
{
//    if()
//    $("#wizard").remove(divTable);

    var imageId = $("#ImageListSelect").val();

    //var request = createRequest(); 
    var strURL = "services/getSamplePoints.aspx";
    
    $.get(strURL,{IMAGEID:imageId,tmp:Math.random()},function(data){
        var xmlDocument = data.documentElement;//xmlDoc.documentElement;
        markerSampleAgriPoints(xmlDocument);
    });
}

//加载样点文件和产量数据
function loadSamplePointsAndYield()
{
    var imageId = $("#ImageListSelect").val();
    var rootId="";
    var distId="";
    var sampDate="";
    rootId=$("#sltProvince").val();//选中的省或直辖市的编号
    distId=$("#sltCounty").val();//选中的二级城市的编号
    var strURL="services/getSamplePointsAndYield.aspx";
    $.get(strURL,{IMAGEID:imageId,RID:rootId,DID:distId,tmp:Math.random()},function(data){
        var xmlDocument = data.documentElement;//xmlDoc.documentElement;
        markerYield(xmlDocument);//已完成11-3日上午
    });
}
 
 //加载样点文件和品质数据、农学参数
 //11-10日添加
function loadSamplePointsAndQuality()
{
    var imageId = $("#ImageListSelect").val();
    var rootId="";
    var distId="";
    var sampDate="";
    rootId=$("#sltProvince").val();//选中的省或直辖市的编号
    distId=$("#sltCounty").val();//选中的二级城市的编号
    var strURL="services/getSamplePointsAndQuality.aspx";//
    $.get(strURL,{IMAGEID:imageId,RID:rootId,DID:distId,tmp:Math.random()},function(data){
        var xmlDocument = data.documentElement;//xmlDoc.documentElement;
        markerQualtity(xmlDocument);
    });
}

 //加载样点文件和品质数据、植被指数
 //11-19日添加
function loadSamplePointsAndRSQuality()
{
    var imageId = $("#ImageListSelect").val();
    var rootId="";
    var distId="";
    var sampDate="";
    rootId=$("#sltProvince").val();//选中的省或直辖市的编号
    distId=$("#sltCounty").val();//选中的二级城市的编号
    var strURL="services/getSamplePointsAndRSQuality.aspx";//修改一下11-19
    $.get(strURL,{IMAGEID:imageId,RID:rootId,DID:distId,tmp:Math.random()},function(data){
        var xmlDocument = data.documentElement;//xmlDoc.documentElement;
        markerRSQualtity(xmlDocument);
    });
}
   
     
function markerSampleAgriPoints(xmlDocument)
{     
//    var SampleParcelsXmlLocation = "data/" + event.data.fileName + ".xml";
//    var xmlDoc = LoadXML(SampleParcelsXmlLocation);
//    var xmlDocument = xmlDoc.documentElement;
//    
    var tableTitleNames = new Array("地块编号","经度","纬度","叶面积指数","叶片含水量","比叶重","植株总干重");
    var tableTitles = new Array();
    for(var i = 0; i < tableTitleNames.length; i++){
        tableTitles[i] = document.createTextNode(tableTitleNames[i]);
    }
    
    var nodes = xmlDocument.getElementsByTagName("Point");
    
    var ParcelsNumber = nodes.length;//xmlDocument.childNodes.length;
    var ParcelsVaule = new Array();
    
//    BrowerType = getBrowserType();
//    if(BrowerType == "MSIE")
//    {
        for(var i = 0; i < ParcelsNumber; i++)
        {
            ParcelsVaule[i] = new Array();
            
            for (var j = 0; j < tableTitles.length; j++)
            {
                ParcelsVaule[i][j] = document.createTextNode(nodes[i].attributes[j].nodeValue);
                //ParcelsVaule[i][j] = document.createTextNode(xmlDocument.childNodes[i].attributes[j].nodeValue);
            }
        }
//    }
//    else
//    {
//        for(var i = 0; i < (ParcelsNumber - 1)/2; i++)
//        {
//            ParcelsVaule[i] = new Array();
//            
//            for (var j = 0; j < tableTitles.length; j++)
//            {
//                //ParcelsVaule[i][j] = document.createTextNode(xmlDocument.childNodes[i].childNodes[j].nodeValue);
//                ParcelsVaule[i][j] = document.createTextNode(xmlDocument.childNodes[i * 2 + 1].attributes[j].nodeValue);
//            }
//        }    
//    }
    
    
    gmap.clearOverlays();
    //var marker = new Array();
    var DLon,DLat,MLon,MLat,SLon,SLat;
    
    for(var i = 0; i < ParcelsNumber; i++ ){
        var pointLocation =new GPoint(parseFloat(ParcelsVaule[i][1].nodeValue),parseFloat(ParcelsVaule[i][2].nodeValue));
        var dmsPoint = tranGLatLngToDMS(pointLocation);
        
        var strHtml = "<table><tr><td>";
        strHtml += "经度</td><td>" + dmsPoint[0] + "</td></tr><tr><td>"; //pointLocation.x  
        strHtml += "纬度</td><td>" +  dmsPoint[1] + "</td></tr><tr><td>";//pointLocation.y
        strHtml += "LAI</td><td>" + ParcelsVaule[i][3].nodeValue + "</td></tr><tr><td>";
        strHtml += "叶片含水量</td><td>" + ParcelsVaule[i][4].nodeValue + "</td></tr><tr><td>";
        strHtml += "比叶重</td><td>" + ParcelsVaule[i][5].nodeValue + "</td></tr><tr><td>";
        strHtml += "生物量</td><td>" + ParcelsVaule[i][6].nodeValue + "</td></tr>";
        strHtml += "</table>";
        
        createMarker(pointLocation, gmap, strHtml);
//        marker[i] = new GMarker(pointLocation);
//        GEvent.addListener(marker, "click", function() {
//            //html=html0 + createMarkerWeather(point, request);;
//            marker[i].openInfoWindowHtml(strHtml);
//        });
//        gmap.addOverlay(marker[i]);
    }
    
    
    var table = new DataTable(tableTitles,ParcelsVaule,0);
    //$(table).addClass("viewTable");
    with($(table))
    {
        width(380);
        height(400);
    }
    
    var divTable = document.createElement("div");
    divTable.className = "resultTable";
    divTable.appendChild(table);
    $("#infoTable").empty();
    document.getElementById("infoTable").appendChild(divTable);
    document.getElementById("infoTable").style.visibility = "visible";
    document.getElementById("DivMenuControl").style.visibility = "visible";
    
}
//11-3日添加
//作用是将样点及单产转成table----->
function markerYield(xmlDocument)
{ 
    var tableTitleNames = new Array("地块编号","经度","纬度","单产(千克)");
    var tableTitles = new Array();
    for(var i = 0; i < tableTitleNames.length; i++){
        tableTitles[i] = document.createTextNode(tableTitleNames[i]);
    }    
    var nodes = xmlDocument.getElementsByTagName("Point");    
    var ParcelsNumber = nodes.length;//xmlDocument.childNodes.length;
    var ParcelsVaule = new Array();
    
        for(var i = 0; i < ParcelsNumber; i++)
        {
            ParcelsVaule[i] = new Array();
            
            for (var j = 0; j < tableTitles.length; j++)
            {
                ParcelsVaule[i][j] = document.createTextNode(nodes[i].attributes[j].nodeValue);
                //ParcelsVaule[i][j] = document.createTextNode(xmlDocument.childNodes[i].attributes[j].nodeValue);
            }
        }
    gmap.clearOverlays();
    var DLon,DLat,MLon,MLat,SLon,SLat;
    
    for(var i = 0; i < ParcelsNumber; i++ ){
        var pointLocation =new GPoint(parseFloat(ParcelsVaule[i][1].nodeValue),parseFloat(ParcelsVaule[i][2].nodeValue));
        var dmsPoint = tranGLatLngToDMS(pointLocation);
        
        var strHtml = "<table><tr><td>";
        strHtml += "经度</td><td>" + dmsPoint[0] + "</td></tr><tr><td>"; //pointLocation.x  
        strHtml += "纬度</td><td>" +  dmsPoint[1] + "</td></tr><tr><td>";//pointLocation.y
        strHtml += "单产(千克)</td><td>" + ParcelsVaule[i][3].nodeValue + "</td></tr>";
        strHtml += "</table>";
        
        createMarker(pointLocation, gmap, strHtml);

    }
    var table = new DataTable(tableTitles,ParcelsVaule,0);
    with($(table))
    {
        width(380);
        height(400);
    }    
    var divTable = document.createElement("div");
    divTable.className = "resultTable";
    divTable.appendChild(table);
    $("#infoTable").empty();
    document.getElementById("infoTable").appendChild(divTable);
    document.getElementById("infoTable").style.visibility = "visible";
    document.getElementById("DivMenuControl").style.visibility = "visible";    
}
//11-3日添加
//<-----作用是将样点及单产转成table

//11-10日添加，将样点与品质数据转成table---->
function markerQualtity(xmlDocument)
{
    var tableTitleNames = new Array("地块编号",
                                    "经度",
                                    "纬度",
                                    "叶片含氮量(NCL)",
                                    "单位土地面积含氮量(CND)",
                                    "鲜叶叶绿素a含量(CHL_A)",
                                    "叶绿素a密度(DEN_CHLA)",
                                    "鲜叶叶绿素总含量(CHL_AB)",
                                    "总叶绿素密度(DEN_CHL)"
                                    );
    var tableTitles = new Array();
    for(var i = 0; i < tableTitleNames.length; i++){
        tableTitles[i] = document.createTextNode(tableTitleNames[i]);
    }
    
    var nodes = xmlDocument.getElementsByTagName("Point");
    
    var ParcelsNumber = nodes.length;//xmlDocument.childNodes.length;
    var ParcelsVaule = new Array();
    

        for(var i = 0; i < ParcelsNumber; i++)
        {
            ParcelsVaule[i] = new Array();
            
            for (var j = 0; j < tableTitles.length; j++)
            {
                ParcelsVaule[i][j] = document.createTextNode(nodes[i].attributes[j].nodeValue);
                //ParcelsVaule[i][j] = document.createTextNode(xmlDocument.childNodes[i].attributes[j].nodeValue);
            }
        }

    
    
    gmap.clearOverlays();
    
    var DLon,DLat,MLon,MLat,SLon,SLat;
    
    for(var i = 0; i < ParcelsNumber; i++ ){
        var pointLocation =new GPoint(parseFloat(ParcelsVaule[i][1].nodeValue),parseFloat(ParcelsVaule[i][2].nodeValue));
        var dmsPoint = tranGLatLngToDMS(pointLocation);
        
        var strHtml = "<table><tr><td>";
        strHtml += "经度</td><td>" + dmsPoint[0] + "</td></tr><tr><td>"; //pointLocation.x  
        strHtml += "纬度</td><td>" +  dmsPoint[1] + "</td></tr><tr><td>";//pointLocation.y
        strHtml += "NCL:</td><td>" + ParcelsVaule[i][3].nodeValue + "</td></tr><tr><td>";
        strHtml += "CND:</td><td>" + ParcelsVaule[i][4].nodeValue + "</td></tr><tr><td>";
        strHtml += "CHL_A:</td><td>" + ParcelsVaule[i][5].nodeValue + "</td></tr><tr><td>";
        strHtml += "DEN_CHLA:</td><td>" + ParcelsVaule[i][6].nodeValue + "</td></tr><tr><td>";
        strHtml += "鲜叶叶绿素总含量(CHL_AB):</td><td>" + ParcelsVaule[i][7].nodeValue + "</td></tr><tr><td>";
        strHtml += "总叶绿素密度(DEN_CHL):</td><td>" + ParcelsVaule[i][8].nodeValue + "</td></tr>";
        strHtml += "</table>";
        
        createMarker(pointLocation, gmap, strHtml);

    }
    
    
    var table = new DataTable(tableTitles,ParcelsVaule,0);
    //$(table).addClass("viewTable");
    with($(table))
    {
        width(380);
        height(400);
    }
    
    var divTable = document.createElement("div");
    divTable.className = "resultTable";
    divTable.appendChild(table);
    $("#infoTable").empty();
    document.getElementById("infoTable").appendChild(divTable);
    document.getElementById("infoTable").style.visibility = "visible";
    document.getElementById("DivMenuControl").style.visibility = "visible";
}

//11-19日添加，将样点与品质数据、植被指数转成table---->
function markerRSQualtity(xmlDocument)
{
    var tableTitleNames = new Array("地块编号",
                                    "经度",
                                    "纬度",
                                    "粗蛋白质含量(%)",
                                    "湿面筋含量(%)",
                                    "稳定时间",
                                    "子粒含氮量(%)"
                                    );
    var tableTitles = new Array();
    for(var i = 0; i < tableTitleNames.length; i++){
        tableTitles[i] = document.createTextNode(tableTitleNames[i]);
    }
    
    var nodes = xmlDocument.getElementsByTagName("Point");
    
    var ParcelsNumber = nodes.length;//xmlDocument.childNodes.length;
    var ParcelsVaule = new Array();
    

        for(var i = 0; i < ParcelsNumber; i++)
        {
            ParcelsVaule[i] = new Array();
            
            for (var j = 0; j < tableTitles.length; j++)
            {
                ParcelsVaule[i][j] = document.createTextNode(nodes[i].attributes[j].nodeValue);
                //ParcelsVaule[i][j] = document.createTextNode(xmlDocument.childNodes[i].attributes[j].nodeValue);
            }
        }

    
    
    gmap.clearOverlays();
    
    var DLon,DLat,MLon,MLat,SLon,SLat;
    
    for(var i = 0; i < ParcelsNumber; i++ ){
        var pointLocation =new GPoint(parseFloat(ParcelsVaule[i][1].nodeValue),parseFloat(ParcelsVaule[i][2].nodeValue));
        var dmsPoint = tranGLatLngToDMS(pointLocation);
        
        var strHtml = "<table><tr><td>";
        strHtml += "经度</td><td>" + dmsPoint[0] + "</td></tr><tr><td>"; //pointLocation.x  
        strHtml += "纬度</td><td>" +  dmsPoint[1] + "</td></tr><tr><td>";//pointLocation.y
        strHtml += "粗蛋白质含量(%):</td><td>" + ParcelsVaule[i][3].nodeValue + "</td></tr><tr><td>";
        strHtml += "湿面筋含量(%):</td><td>" + ParcelsVaule[i][4].nodeValue + "</td></tr><tr><td>";
        strHtml += "稳定时间:</td><td>" + ParcelsVaule[i][5].nodeValue + "</td></tr><tr><td>";
        strHtml += "子粒含氮量(%):</td><td>" + ParcelsVaule[i][6].nodeValue + "</td></tr>";
        strHtml += "</table>";
        
        createMarker(pointLocation, gmap, strHtml);

    }
    
    
    var table = new DataTable(tableTitles,ParcelsVaule,0);
    //$(table).addClass("viewTable");
    with($(table))
    {
        width(380);
        height(400);
    }
    
    var divTable = document.createElement("div");
    divTable.className = "resultTable";
    divTable.appendChild(table);
    $("#infoTable").empty();
    document.getElementById("infoTable").appendChild(divTable);
    document.getElementById("infoTable").style.visibility = "visible";
    document.getElementById("DivMenuControl").style.visibility = "visible";
}


//function setAlert(s)
//{
//    //alert(s);
//    $("#content1").css("visibility","hidden");
//    $("#content2").css("visibility","visible");
//}


function handleToolClick(event)
{
    var ToolId = event.data.id;

    switch(ToolId)
    {
        case "PanUp":
            gmap.panDirection(0,  -1);
            break;

        case "PanLeft":
            gmap.panDirection(-1,  0);
            break;

        case "PanRight":
            gmap.panDirection(+1,  0);
            break;

        case "LastView":
            gmap.returnToSavedPosition();
            break;

        case "PanDown":
            gmap.panDirection(0,  +1);
            break;

        case "ZoomIn":
            gmap.zoomIn();
            break;

        case "ZoomOut":
            gmap.zoomOut();
            break;

        default:
            break;
        
    }
    gmap.savePosition();
    
    getIMSMap("map");
}

function handleMouseDown()
{
	//var evt = event || window.event;
	if(MAP_TYPE == "GMAP") return;
	var eventX;
	var eventY;
	eventX = event.clientX;
	eventY = event.clientY;
	if(EventOverMap(eventX,eventY)) return;
    StartX = eventX;
    StartY = eventY;
    document.getElementById("map").setCapture(); 

}

function handleMouseUp()
{
//	var evt = event || window.event;
	if(MAP_TYPE == "GMAP") return;
	var eventX;
	var eventY;
	eventX = event.clientX;
	eventY = event.clientY;
	if(EventOverMap(eventX,eventY)) return;
    EndX = eventX;
    EndY = eventY;
    
    document.releaseCapture();
    
    var xDistance = EndX - StartX;
    var yDistance = EndY - StartY;
    var distanse = new GSize(xDistance,yDistance);
    //var center = gmap.getCenter();
    gmap.panBy(distanse);
    gmap.savePosition();
    
    getIMSMap("map");
    
}


function handleMouseMove()
{

}


function EventOverMap(x,y)
{
    
    var i = 0;
    var offsetTop = 0;
    var offsetLeft = 0;
    
    var mapElem = $("#map");
    
    for (var elem = mapElem; elem; elem = elem.offsetParent()) 
    {
        offsetTop += elem.offset().top;
        offsetLeft += elem.offset().left;
        i++;
        if (i>10) break;
    }
    
    if(x < offsetLeft) return true;
    if(y < offsetTop) return true;
    if(x > (offsetLeft+800)) return true;
    if(y > (offsetTop+500)) return true;
    return false;
}


//*************************************************************************灾害监测—病虫害（宫）*********************************************************************************
//加载病虫害样点观测数据
function loadSamplePointsTable_disease()
{
    var imageId = $("#ImageListSelect").val();

    //var request = createRequest(); 
    var strURL = "services/getSamplePoints_disease.aspx";
    
    $.get(strURL,{IMAGEID:imageId,tmp:Math.random()},function(data){
        //alert(data);
        var xmlDocument = data.documentElement;//xmlDoc.documentElement;
        markerSampleDiseasePoints(xmlDocument);
    });
}

     
//**********************************************************************************************************************************************************    


//************************************************************灾害监测-病虫害（宫）********************************************************************************************
//显示病虫害样点
function markerSampleDiseasePoints(xmlDocument)
{     
//    var SampleParcelsXmlLocation = "data/" + event.data.fileName + ".xml";
//    var xmlDoc = LoadXML(SampleParcelsXmlLocation);
//    var xmlDocument = xmlDoc.documentElement;

    var tableTitleNames = new Array("地块编号","经度","纬度","病虫害名称","病情指数","叶面积指数","叶片含水量","干物质量");
    var tableTitles = new Array();
    for(var i = 0; i < tableTitleNames.length; i++){
        tableTitles[i] = document.createTextNode(tableTitleNames[i]);
    }
    
    var nodes = xmlDocument.getElementsByTagName("Point");
    
    var ParcelsNumber = nodes.length;//xmlDocument.childNodes.length;
    var ParcelsVaule = new Array();
    
//    BrowerType = getBrowserType();
//    if(BrowerType == "MSIE")
//    {
        for(var i = 0; i < ParcelsNumber; i++)
        {
            ParcelsVaule[i] = new Array();
            
            for (var j = 0; j < tableTitles.length; j++)
            {
                ParcelsVaule[i][j] = document.createTextNode(nodes[i].attributes[j].nodeValue);
                //ParcelsVaule[i][j] = document.createTextNode(xmlDocument.childNodes[i].attributes[j].nodeValue);
            }
        }
//    }
//    else
//    {
//        for(var i = 0; i < (ParcelsNumber - 1)/2; i++)
//        {
//            ParcelsVaule[i] = new Array();
//            
//            for (var j = 0; j < tableTitles.length; j++)
//            {
//                //ParcelsVaule[i][j] = document.createTextNode(xmlDocument.childNodes[i].childNodes[j].nodeValue);
//                ParcelsVaule[i][j] = document.createTextNode(xmlDocument.childNodes[i * 2 + 1].attributes[j].nodeValue);
//            }
//        }    
//    }
    
    
    gmap.clearOverlays();
    //var marker = new Array();
    var DLon,DLat,MLon,MLat,SLon,SLat;
    
    for(var i = 0; i < ParcelsNumber; i++ ){
        var pointLocation =new GPoint(parseFloat(ParcelsVaule[i][1].nodeValue),parseFloat(ParcelsVaule[i][2].nodeValue));
        var dmsPoint = tranGLatLngToDMS(pointLocation);
        //var tableTitleNames = new Array("地块编号","经度","纬度","病虫害名称","病情指数","叶面积指数","叶片含水量","干物质量");
        var strHtml = "<table><tr><td>";
        strHtml += "经度</td><td>" + dmsPoint[0] + "</td></tr><tr><td>"; //pointLocation.x  
        strHtml += "纬度</td><td>" +  dmsPoint[1] + "</td></tr><tr><td>";//pointLocation.y
        strHtml += "病虫害名称</td><td>" + ParcelsVaule[i][3].nodeValue + "</td></tr><tr><td>";
        strHtml += "病情指数</td><td>" + ParcelsVaule[i][4].nodeValue + "</td></tr><tr><td>";
        strHtml += "叶面积指数</td><td>" + ParcelsVaule[i][5].nodeValue + "</td></tr><tr><td>";
        strHtml += "叶片含水量</td><td>" + ParcelsVaule[i][6].nodeValue + "</td></tr><tr><td>";
        strHtml += "干物质量</td><td>" + ParcelsVaule[i][7].nodeValue + "</td></tr>";
        strHtml += "</table>";
        
        createMarker(pointLocation, gmap, strHtml);
//        marker[i] = new GMarker(pointLocation);
//        GEvent.addListener(marker, "click", function() {
//            //html=html0 + createMarkerWeather(point, request);;
//            marker[i].openInfoWindowHtml(strHtml);
//        });
//        gmap.addOverlay(marker[i]);
    }
    
    
    var table = new DataTable(tableTitles,ParcelsVaule,0);
    //$(table).addClass("viewTable");
    with($(table))
    {
        width(380);
        height(400);
    }
    
    var divTable = document.createElement("div");
    divTable.className = "resultTable";
    divTable.appendChild(table);
    $("#infoTable").empty();
    document.getElementById("infoTable").appendChild(divTable);
    document.getElementById("infoTable").style.visibility = "visible";
    document.getElementById("DivMenuControl").style.visibility = "visible";
    
}

function markerSampleRSPoints_disease(xmlDocument)
{
//NDWI, NDWI2, NDVI, NRI, NSI, WI, G-SWIR, G-SWIR2，EVI,RVI,ARVI,SAVI,MSAVI,DVI,RDVI
    var tableTitleNames = new Array("地块编号","经度","纬度","NDWI", "NDWI2", "NDVI", "NRI", "NSI", "WI", "GWIR", "GWIR2","EVI","ARVI","SAVI","MSAVI","DVI","RDVI","病情指数","叶绿素","叶面积指数","叶片含水量");
    var tableTitles = new Array();
    for(var i = 0; i < tableTitleNames.length; i++){
        tableTitles[i] = document.createTextNode(tableTitleNames[i]);
    }
    var nodes = xmlDocument.getElementsByTagName("Parcel");
    var ParcelsNumber = nodes.length;//xmlDocument.childNodes.length;
    
    
    var ParcelsVaule = new Array();
    
    
    for(var i = 0; i < ParcelsNumber; i++)
    {
        ParcelsVaule[i] = new Array();
        ParcelsVaule[i][0] = document.createTextNode(nodes[i].attributes[0].nodeValue);  //pointid
        ParcelsVaule[i][1] = document.createTextNode(nodes[i].attributes[2].nodeValue); //lat
        ParcelsVaule[i][2] = document.createTextNode(nodes[i].attributes[3].nodeValue); //lon
        ParcelsVaule[i][3] = document.createTextNode(nodes[i].attributes[6].nodeValue); //ndwi
        ParcelsVaule[i][4] = document.createTextNode(nodes[i].attributes[7].nodeValue); //ndwi2
        ParcelsVaule[i][5] = document.createTextNode(nodes[i].attributes[8].nodeValue); //ndvi
        ParcelsVaule[i][6] = document.createTextNode(nodes[i].attributes[9].nodeValue); //NRI
        ParcelsVaule[i][7] = document.createTextNode(nodes[i].attributes[10].nodeValue); //NSI
        ParcelsVaule[i][8] = document.createTextNode(nodes[i].attributes[11].nodeValue);//WI
        ParcelsVaule[i][9] = document.createTextNode(nodes[i].attributes[12].nodeValue);//G_SWIR
        ParcelsVaule[i][10] = document.createTextNode(nodes[i].attributes[13].nodeValue);//G_SWIR2
        ParcelsVaule[i][11] = document.createTextNode(nodes[i].attributes[14].nodeValue);//EVI
        ParcelsVaule[i][12] = document.createTextNode(nodes[i].attributes[15].nodeValue);//,RVI
        ParcelsVaule[i][13] = document.createTextNode(nodes[i].attributes[16].nodeValue);//,ARVI
        ParcelsVaule[i][14] = document.createTextNode(nodes[i].attributes[17].nodeValue);//,MSAVI
        ParcelsVaule[i][15] = document.createTextNode(nodes[i].attributes[18].nodeValue);//,DVI
        ParcelsVaule[i][16] = document.createTextNode(nodes[i].attributes[19].nodeValue);//,RDVI
        ParcelsVaule[i][17] = document.createTextNode(nodes[i].attributes[20].nodeValue);//病情指数
        ParcelsVaule[i][18] = document.createTextNode(nodes[i].attributes[21].nodeValue);//叶面积指数
        ParcelsVaule[i][19] = document.createTextNode(nodes[i].attributes[22].nodeValue);//叶片含水量
        ParcelsVaule[i][20] = document.createTextNode(nodes[i].attributes[23].nodeValue);//,SAVI
    }
    
    gmap.clearOverlays();
    //var marker = new Array();
    for(var i = 0; i < ParcelsNumber; i++ ){
        var pointLocation =new GPoint(parseFloat(ParcelsVaule[i][1].nodeValue),parseFloat(ParcelsVaule[i][2].nodeValue));
        var strHtml = "<table><tr><td>";
        strHtml += "X</td><td>" + pointLocation.x + "</td></tr><tr><td>";
        strHtml += "Y</td><td>" + pointLocation.y + "</td></tr><tr><td>";
        strHtml += "LAI</td><td>" + ParcelsVaule[i][12].nodeValue + "</td></tr><tr><td>";
        strHtml += "叶片含水量</td><td>" + ParcelsVaule[i][14].nodeValue + "</td></tr><tr><td>";
        strHtml += "NDVI</td><td>" + ParcelsVaule[i][5].nodeValue + "</td></tr><tr><td>";
        strHtml += "NDWI</td><td>" + ParcelsVaule[i][3].nodeValue + "</td></tr>";
        strHtml += "</table>";

        
        createMarker(pointLocation, gmap, strHtml);
//        marker[i] = new GMarker(pointLocation);
//        GEvent.addListener(marker, "click", function() {
//            //html=html0 + createMarkerWeather(point, request);;
//            marker[i].openInfoWindowHtml(strHtml);
//        });
//        gmap.addOverlay(marker[i]);
    }
    
    
    var table = new DataTable(tableTitles,ParcelsVaule,0);
    //$(table).addClass("viewTable");
    with($(table))
    {
        width(380);
        height(400);
    }
    
    var divTable = document.createElement("div");
    divTable.className = "resultTable";
    divTable.appendChild(table);
    
    with($("#infoTable"))
    {
        empty();
        append(divTable);
        css("visibility", "visible");
    }
    $("#DivMenuControl").css("visibility", "visible");
    hideWaitImage();

}
//********************************************************************************************************************************************************
